<extend name="Public/base"/>
<block name="content">
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">设置领导人</strong>  <small></small></div>
            </div>

            <hr/>

            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-8 am-u-md-push-1">
                    <div class="am-form am-form-horizontal"  >
                        <input type="hidden" name="id" id="id" value="{$user.id}">
                        <div class="am-form-group">
                            <label for="username" class="am-u-sm-3 am-form-label">用户昵称</label>
                            <div class="am-u-sm-9">
                                <input type="text" id="username" placeholder="" required name="title" value="{$user.username}" readonly>
                            </div>
                        </div>
                        <div class="am-form-group">

                            <label for="level" class="am-u-sm-3 am-form-label">用户等级</label>
                            <div class="am-u-sm-9">
                                <select name="level" id="level">
                                    <option value="0" <if condition="$user.level eq 0">selected</if>>V1</option>
                                    <option value="1" <if condition="$user.level eq 1">selected</if>>V2</option>
                                    <option value="2" <if condition="$user.level eq 2">selected</if>>V3</option>
                                </select>
                            </div>

                        </div>
                        <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button type="button" class="am-btn am-btn-primary sub">保存修改</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="js">
    <script src="__COMMON__/js/jquery.min.js"></script>
    <script>
        $(".sub").click(function () {
            $.ajax({
                type:"post",
                dataType:"json",
                url:"{:U('modeLevel')}",
                data:{
                    id:$("#id").val(),
                    level:$("#level").val(),
                },
                success:function (data) {
                    if(data.code>0){
                        alert(data.msg);
                        history.go(-1);
                        // window.location.href=data.data;
                    }else {
                        alert(data.msg);
                    }
                }
            })
        })

//        $(function () {
//            var form = $('form');
//
//            $('form').submit(function (e) {
//
//                e.preventDefault();
//                $.post(form.attr('action'),form.serialize(),function (data) {
//                    layer.msg(data.msg,{time:1000},function () {
//                        if(data.code){
//                            return false;
//                        }else{
//                            window.location.href=data.data;
//                        }
//                    })
//
//                },'json')
//            })
//        })
    </script>
</block>